<?php

namespace app\admin\model\ykjp\information\financeinfo;

use think\Model;
use traits\model\SoftDelete;

class Settlementaccount extends Model {

    use SoftDelete;

    // 表名
    protected $name = 'ykjp_settlement_account';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';
    // 追加属性
    protected $append = [
        'type_text',
        'status_text'
    ];

    public function getTypeList() {
        return ['现金' => __('现金'), '银行账号' => __('银行账号'), '支付宝' => __('支付宝'), '微信钱包' => __('微信钱包'), '其他' => __('其他')];
    }

    public function getStatusList() {
        return ['正常' => __('正常'), '禁用' => __('禁用')];
    }

    public function getTypeTextAttr($value, $data) {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getStatusTextAttr($value, $data) {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    protected function object_array($array) {
        if (is_object($array)) {
            $array = (array) $array;
        } if (is_array($array)) {
            foreach ($array as $key => $value) {
                $array[$key] = $this->object_array($value);
            }
        }
        return $array;
    }

}
